package org.baicaixiaozhan.learncommon.util;

import org.springframework.retry.annotation.Recover;

import java.util.List;
import java.util.Optional;

/**
 * DESC: 复原（异常补救）回调
 *
 * @author baicaixiaozhan
 * @since 2021-07-07
 */
public interface RecoveryCallback<E extends Throwable> {

    /**
     * 执行复原（异常补救）方法，实现该方法后需要标记 {@link Recover} 注解
     *
     * @param e
     * @param scriptName
     * @param key
     * @param args
     * @param <R>
     * @return
     */
    default <R> Optional<R> recover(E e, String scriptName, List<String> key, Object... args) { return Optional.empty(); }

}
